/**
 * timewindowconstraint.cpp is part of %PROJECTNAME%.
 *
 * %PROJECTNAME% is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * %PROJECTNAME% is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with %PROJECTNAME%.  If not, see <http://www.gnu.org/licenses/>.
 */

#include "tasktimewindowconstraint.h"
#include "../../utils/visitor/visitor.h"
#include <sstream>

const std::string TaskTimeWindowConstraint::TASK_TIME_WINDOW_CONSTRAINT = "Time window";

TaskTimeWindowConstraint::TaskTimeWindowConstraint( tTime a_start, tTime a_end ) :
    TaskConstraint(),
    m_start( a_start ),
    m_end( a_end )
{
}

TaskTimeWindowConstraint::~TaskTimeWindowConstraint()
{
    m_start = MIN_TIME;
    m_end   = MAX_TIME;
}

void TaskTimeWindowConstraint::Accept( Visitor * a_visitor )
{
    if( a_visitor )
        a_visitor->Visit( this );
}

std::string TaskTimeWindowConstraint::Print() const
{
    std::ostringstream strStream;
    strStream << TASK_TIME_WINDOW_CONSTRAINT << ": start = " << m_start << " end = " << m_end;

    return strStream.str();
}

void TaskTimeWindowConstraint::Start( tTime a_start )
{
    m_start = a_start;
}

tTime TaskTimeWindowConstraint::Start() const
{
    return m_start;
}

void TaskTimeWindowConstraint::End( tTime a_end )
{
    m_end = a_end;
}

tTime TaskTimeWindowConstraint::End() const
{
    return m_end;
}
